<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
    <title>购物车</title>
    <meta name="keywords" content="关键词,5个左右,单个8汉字以内">
    <meta name="description" content="网站描述，字数尽量空制在80个汉字，160个字符以内！">
    <link rel="Bookmark" href="favicon.ico">

    <link href="../css/reset.css" rel="stylesheet" type="text/css"/>
    <link href="../css/style.css" rel="stylesheet" type="text/css"/>
</head>

<body>
<#include "../common/header.ftl" />
<@person></@person>
<input type="hidden" id="cartIds" value=""/>
<@personheader></@personheader>

<div class="container cf accortop">
<#include "../common/personnavigation.ftl" />
<@personnavigation></@personnavigation>
    <!---->
    <div class="orderlist">
        <h1>全部商品</h1>
        <section class="cartMain">
            <div class="cartMain_hd">
                <ul class="order_lists cartTop">
                    <li class="list_chk">
                        <input type="checkbox" id="all" class="whole_check">
                        <label for="all"></label> 全选
                    </li>
                    <li class="list_info">商品编号</li>
                    <li class="list_con">商品名称</li>

                    <li class="list_price">单价(元)</li>
                    <li class="list_amount">数量</li>
                    <li class="list_sum">金额</li>
                    <li class="list_op">操作</li>
                </ul>
            </div>
        <#if HfTaobaoShopList??>
            <#list HfTaobaoShopList as taobaoShop>
            <div class="cartBox">
                    <div class="shop_info">
                        <div class="all_check">
                            <!--店铺全选-->
                            <input type="checkbox" id="shop_${taobaoShop_index}" class="shopChoice">
                            <label for="shop_${taobaoShop_index}" class="shop"></label>
                        </div>
                        <div class="shop_name">
                            店铺：
                            <a href="javascript:;">${taobaoShop.address}</a>
                        </div>
                    </div>


                <div class="order_content">
                <#if shoppingCartList??>
                    <#list shoppingCartList as shopCart>
                    <#if taobaoShop.shopId == shopCart.shopId>
                        <ul class="order_lists">
                            <li class="list_chk">
                                <input type="checkbox" id="checkbox_${shopCart_index}" name="checkbox_8" class="son_check" value="${shopCart.cartId?long?c}" >
                                <label for="checkbox_${shopCart_index}"></label>
                            </li>
                            <li class="list_info">${shopCart.hfGoodId?long?c}</li>
                            <li class="list_con">
                                <div class="list_img">
                                    <a href="javascript:;"><img src="${shopCart.smallPicture}" alt=""></a>
                                </div>
                                <div class="list_text">
                                    <a href="javascript:;">${shopCart.goodTitle}</a>
                                    <p style="color: blue">${shopCart.color}+${shopCart.size}</p>
                                </div>
                            </li>

                            <li class="list_price">
                                <p class="price">￥${shopCart.taobaoPrice/100}</p>
                            </li>
                            <li class="list_amount">
                                <div class="amount_box">
                                    <a href="javascript:;" class="reduce reSty">-</a>
                                    <input type="text" value="${shopCart.count}" class="sum">
                                    <a href="javascript:;" class="plus">+</a>
                                </div>
                            </li>
                            <li class="list_sum">
                                <p class="sum_price">￥${shopCart.taobaoPrice/100*shopCart.count}</p>
                            </li>
                            <li class="list_op">
                                <p class="del">
                                    <a href="javascript:;" class="delBtn">移除商品</a>
                                </p>
                            </li>
                        </ul>
                    </#if>
                    </#list>
                </#if>
                </div>
            </div>
            </#list>
        </#if>
            <!--底部-->
            <div class="bar-wrapper">
                <div class="bar-right">
                    <div class="piece">已选商品<strong class="piece_num">0</strong>件</div>
                    <div class="totalMoney">共计: <strong class="total_text">0.00</strong></div>
                    <div class="calBtn">
                        <a href="javascript:;" onclick="assembleGoodsId()">去下单</a>
                    </div>
                </div>
            </div>
        </section>
        <section class="model_bg"></section>
        <section class="my_model">
            <p class="title">删除宝贝
                <!--<span class="closeModel">X</span>--></p>
            <p>您确认要删除该宝贝吗？</p>
            <div class="opBtn">
                <a href="javascript:;" class="dialog-sure">确定</a>
                <a href="javascript:;" class="dialog-close">关闭</a>
            </div>
        </section>

    </div>
</div>

<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/carts.js"></script>
<script>
    $(function () {
        // nav收缩展开
        $('.navMenu li a').on('click', function () {
            var parent = $(this).parent().parent(); //获取当前页签的父级的父级
            var labeul = $(this).parent("li").find(">ul")
            if ($(this).parent().hasClass('open') == false) {
                //展开未展开
                parent.find('ul').slideUp(300);
                parent.find("li").removeClass("open")
                parent.find('li a').removeClass("active").find(".icon-under").removeClass("open")
                $(this).parent("li").addClass("open").find(labeul).slideDown(300);
                $(this).addClass("active").find(".icon-under").addClass("open")
            } else {
                $(this).parent("li").removeClass("open").find(labeul).slideUp(300);
                if ($(this).parent().find("ul").length > 0) {
                    $(this).removeClass("active").find(".icon-under").removeClass("open")
                } else {
                    $(this).addClass("active")
                }
            }

        });
    });

    function assembleGoodsId(){
        var checkBoxes =  $("input[name='checkbox_8']");
        var cartIdArray=new Array();
        var index =0;
        for(var i=0;i<checkBoxes.length;i++){
            if(checkBoxes[i].checked){
                cartIdArray[index]=checkBoxes[i].value;
                index++;
            }

        }
        $('#cartIds').val(cartIdArray);
        console.log( $('#cartIds').val());
        saveOrder();
    }

    /**
     * 保存购物车订单
     */
    function saveOrder(){
        var cartIds = $('#cartIds').val();
        $.ajax({
           url:'/user/saveOrder',
           type:'post',
           data:{'cartIds':cartIds},
           success:function(status){
                window.location.href="/user/showOrderDetail"
           }
        });
    }

    function  showclick() {
      //  alert($(el).val());
       var checkBoxes =  $("input[class='son_check']");
       for(var i=0;i<checkBoxes.length;i++){
           if(checkBoxes[i].checked){
               alert(checkBoxes[i].value);
           }

       }
    }
</script>
</body>

</html>